import { JsonController, Authorized, Body, HeaderParam, Get, Post, UseBefore, QueryParam} from 'routing-controllers';
import { RequestLog } from '@/middledware/requestLog'
import { Inject, Service } from 'typedi';
import { ArticleServiceImpl } from '../../service/impl/ArticleServiceImpl';
import { JsonResult, msgList, res } from '@/utils/jsonResult';
import { User } from '@/m_res/user'
import config from '@/config/init'

@Service()
@JsonController(config.setPrefix("app/article"))
export class ArticleController {

  @Inject()
  articleServiceImpl!: ArticleServiceImpl;

  @Inject()
  json!: JsonResult<any>;

  @Get('/label')
  @UseBefore(RequestLog) //全部标签
   async Articlelabel(){
     return await this.articleServiceImpl.GetArticlelabel() 
  }

  @Get('/Labeldetails')
  @UseBefore(RequestLog) //标签 详情
   async ArticleLabeldetails(@QueryParam("id") id: number){
     return await this.articleServiceImpl.GetArticlelabeldetails(id) 
  }

  @Get('/categories_list')
  @UseBefore(RequestLog)  //分类 全部
  async GetCategoriesList() {
    return await this.articleServiceImpl.GetCategoriesList();
  }

  @Get('/categories_info')
  @UseBefore(RequestLog)  //分类 详情
  async GetArticgoriesListinfo(@QueryParam("id") id:number) {
    return await this.articleServiceImpl.GetArticgoriesListinfo(id);
  }

  @Get('/Search')
  @UseBefore(RequestLog)  //分类 详情
  async GetArticSearch(@QueryParam("text") text:string) {
    return await this.articleServiceImpl.GetSearch(text);
  }
  
}